#include <iostream>
#include <stack>
#include <string>
#include <vector>

using ll = long long;

const ll max_n = 5e5;
ll n, father;
std::string s;
std::vector<ll> son[max_n];
char c[max_n];

void dfs(const ll now, const std::stack<char> &parenthesis){
    

    for(const auto i:son[now]){
        auto new_parenthesis = parenthesis;
        new_parenthesis.push(c[i]);
        dfs(i, new_parenthesis);
    }
}

int main(){
    std::cin>>n;
    std::cin>>s;
    for(ll i{1};i<=n;i++){
        c[i]=s[i-1];
    }
    for(ll i{2};i<=n;i++){
        std::cin>>father;
        son[father].push_back(i);
    }

    std::stack<char> first_parenthesis;
    first_parenthesis.push(c[1]);
    dfs(1, first_parenthesis);
}